package com.music.checkpoints.common.handler;


import com.music.checkpoints.common.exception.ServiceException;
import com.music.checkpoints.common.utils.ResultVOUtil;
import com.music.checkpoints.common.vo.ResultVO;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ServiceExceptionHandler {

    @ExceptionHandler(value = ServiceException.class)
    @ResponseBody
    public ResultVO handlerServiceException(ServiceException e) {
        return ResultVOUtil.error(e.getCode(), e.getMessage());
    }
}
